package io.renren.modules.avanotes.service.impl;

import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.*;
import io.renren.common.vo.output.SpecialSubjectVo;
import io.renren.modules.avanotes.dao.ReferenceBankDao;
import io.renren.modules.avanotes.dao.SpecialSubjectDao;
import io.renren.modules.avanotes.dao.SpecialSubjectWorkDao;
import io.renren.modules.avanotes.entity.ReferenceBankEntity;
import io.renren.modules.avanotes.entity.ReferenceMaterialEntity;
import io.renren.modules.avanotes.entity.SpecialSubjectEntity;
import io.renren.modules.avanotes.entity.SpecialSubjectWorkEntity;
import io.renren.modules.avanotes.service.ReferenceBankService;
import io.renren.modules.avanotes.service.SpecialSubjectService;
import io.renren.modules.avanotes.service.SpecialSubjectWorkService;
import io.renren.modules.sys.entity.SysUserEntity;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


//@Service("specialSubjectWorkService")//默认只有一个实现，那就不写名称了直接使用默认的名称！
@Service
public class SpecialSubjectWorkServiceImpl extends ServiceImpl<SpecialSubjectWorkDao, SpecialSubjectWorkEntity> implements SpecialSubjectWorkService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SpecialSubjectWorkEntity> page = this.page(
                new Query<SpecialSubjectWorkEntity>().getPage(params),
                new QueryWrapper<SpecialSubjectWorkEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Integer insert(SpecialSubjectWorkEntity param) {
        String name = BizUtils.getFileNameByPath(param.getPath());
        param.setTitle(name);
        SysUserEntity userEntity = ShiroUtils.getUserEntity();
        param.setCreateUserId(userEntity.getUserId());
        this.save(param);
        return param.getId();
    }

}